﻿namespace Example.Standalone
{
    using System.Threading;
    using System.Windows;
    using System.Windows.Input;

    /// <summary>
    /// Interaktionslogik für MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            this.InitializeComponent();

            this.ReportList.Items.Clear();
            foreach (var item in this.CrumbleCoreControl.GetReportList())
            {
                this.ReportList.Items.Add(new ReportList { UniqueId = item.Key, ReportName = item.Value });
            }
        }

        private void ReportList_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            var reportClass = (ReportList)this.ReportList.SelectedItem;
            this.CrumbleCoreControl.ResetReport();
            this.CrumbleCoreControl.ShowReportThread = this.CrumbleCoreControl.Show;
            var loadData = new Thread(() => this.CrumbleCoreControl.Load(reportClass.UniqueId, this.CrumbleCoreControl.ShowReportThread));
            loadData.Start();
        }
    }
}
